package response

import (
	"encoding/json"
	"log"
)

type Response struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}

func New(code int, data interface{}, msg string) []byte {
	resp := &Response{
		Code: code,
		Data: data,
		Msg:  msg,
	}
	str, err := json.Marshal(resp)
	if err != nil {
		log.Fatal(err)
	}
	return str
}
